apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'de.mannodermaus.android-junit5'
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'kotlin-parcelize'

repositories {
    mavenCentral()
    google()
    maven {
        url 'https://jitpack.io'
        content {
            includeModule('com.github.IvanShafran', 'shared-preferences-mock')
            includeModule('com.github.topjohnwu.libsu', 'core')
        }
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'

    implementation 'androidx.appcompat:appcompat:1.5.1'

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.work:work-runtime-ktx:2.7.1'

    // solve dependency conflict https://stackoverflow.com/a/69832319
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'

    // has kotlinx-coroutines-android
    implementation 'androidx.preference:preference-ktx:1.2.0'

    // has coordinatorlayout, constraintlayout, cardview and more
    implementation 'com.google.android.material:material:1.6.1'

    // additional layout for then main screen
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

    // parse API responses in JSON
    implementation 'com.google.code.gson:gson:2.9.0'

    // compare versions of available and installed apps
    implementation 'io.github.g00fy2:versioncompare:1.5.0'

    // for file downloader
    implementation 'com.squareup.okhttp3:okhttp:4.10.0'
    implementation 'ru.gildor.coroutines:kotlin-coroutines-okhttp:1.0'

    // for root installer
    implementation 'com.github.topjohnwu.libsu:core:4.0.3'

    // Aggregator dependency on JUnit api, engine, and params
    testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
    testImplementation 'io.mockk:mockk:1.10.5'
    testImplementation 'com.github.IvanShafran:shared-preferences-mock:1.1'
}

android {
    compileSdkVersion 32

    defaultConfig {
        versionCode 115
        versionName "77.3.1" // MAJOR.MINOR.PATCH
        // MAJOR version when you make incompatible API changes,
        // MINOR version when you add functionality in a backwards compatible manner, and
        // PATCH version when you make backwards compatible bug fixes.
        minSdkVersion 21
        targetSdkVersion 32
        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        encoding = "UTF-8"
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    packagingOptions {
        resources {
            excludes += ['META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/README', 'META-INF/README.txt',
                         'META-INF/LICENSE', 'META-INF/LICENSE.txt']
        }
    }

    testOptions {
        // workaround for "Method i in android.util.Log not mocked"
        // without PowerMockito it is impossible to mock Log.
        unitTests.returnDefaultValues = true
        unitTests.includeAndroidResources = true
        unitTests.all {
            testLogging {
                events "passed", "skipped", "failed", "standardOut", "standardError"
                outputs.upToDateWhen { false }
                showStandardStreams = true
            }
        }
    }

    lint {
        abortOnError false
    }
}
